package com.heartskyhigh.product.VO;

import com.heartskyhigh.product.enums.ServerStatusEnum;
import lombok.Data;

/**
 * 返回参数类型
 *
 * @author Luo Zhen
 * @create 2019-11-18 15:36
 */
@Data
public class ResultVO<T> {

    private Integer code;

    private String msg;

    private T data;

    public ResultVO() {

    }

    public ResultVO(Integer code, T data) {
        this.code = code;
        this.data = data;
    }

    public ResultVO(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> ResultVO<T> ok(T object) {
        return new ResultVO<T>(ServerStatusEnum.OK.getCode(), "success", object);
    }

    public static <T> ResultVO<T> error(String msg, T data) {
        return new ResultVO<T>(ServerStatusEnum.ERROR.getCode(), msg, data);
    }
}
